#include "stdafx.h"

#include "PFEvent.h"
#include "PFControllor.h"
#include "PortfilioDef.h"

PFControllor::PFControllor()
{

}

PFControllor::~PFControllor()
{

}

void PFControllor::InstallFilter(PFControllor * filter)
{
	auto iter = std::find(m_pFilters.begin(), m_pFilters.end(), filter);
	if (iter == m_pFilters.end())
	{
		m_pFilters.push_back(filter);
	}
}

void PFControllor::RemoveFilter(PFControllor * filter)
{
	auto iter = std::find(m_pFilters.begin(), m_pFilters.end(), filter);
	if (iter != m_pFilters.end())
	{
		m_pFilters.erase(iter);
	}
}

void PFControllor::SendFilterEvent(PFEvent * event) const
{
	for (auto iter = m_pFilters.begin(); iter != m_pFilters.end(); ++iter)
	{
		(*iter)->OnFilterEvent(event);
	}
}

void PFControllor::OnFilterEvent(PFEvent * event)
{
#ifdef _DEBUG
	if (event->type == PFEventType::EPFET_SecutiryQuote)
	{
		PFPositionEvent * positionEvent = static_cast<PFPositionEvent *>(event);
	}
#endif
}
